#ifndef QCLICKABLELABEL_H
#define QCLICKABLELABEL_H

#include <QLabel>
#include <iostream>
#include <QDebug>

/* Class clickableLabel extends QLabel
 * to add the ability of the user to click on a label
 * and for a signal to be emitted
 */
class QClickableLabel : public QLabel
{
    Q_OBJECT
public:
    QClickableLabel(QWidget *parent = 0);
    ~QClickableLabel();

    void setClickablePixmap(const QPixmap &);

protected:
    void mousePressEvent(QMouseEvent *event);
    void mouseDoubleClickEvent(QMouseEvent *event);
    /*
     * Resize event is responsible for maintaining aspect ratio
     */
    void resizeEvent(QResizeEvent * event);
    /*
     * Draw a border
     */
    void paintEvent(QPaintEvent * event);

private:
    /**
     * Image to draw
     */
    QPixmap originalImage;
    /**
     * Size of image scaled with aspect ratio.
     * Set in resizeEvent().
     */
    QSize scaledSize;

signals:
    void clicked();
    void doubleClicked();

};

#endif // QCLICKABLELABEL_H
